
<?php
    $url = new Url();
    $arr_region = LoadConfig::$region;

    $forder_upload = "avatarxs"; 
    $link_avatar = Yii::app()->params["urlImages"]."upload.php?forder_upload=".$forder_upload;
    $link_url = Yii::app()->params["urlImages"]."upload_base.php?forder_upload=".$forder_upload; 
    //var_dump($link_avatar);
?>
<script type="text/javascript" src="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/js/swfupload.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/js/swfupload.queue.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/js/fileprogress.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/js/handlers.js"></script>
<script type="text/javascript">

    window.onload = function() {
        var configUploadData = {
            flash_url:"<?php echo Yii::app()->params["urlImages"];?>lib_upload/js/swfupload.swf",
            create_date:"<?php echo $date;?>",
            button_image_url:"<?php echo Yii::app()->params["urlImages"];?>lib_upload/images/buttonUpload3.png",
            upload_url: "<?php echo $link_avatar;?>", 
            file_types: "*.jpg;*.jpeg;*.png;*.gif", 
            file_upload_limit : 20, 
            file_queue_limit : 1, 
            debug : false
        }
        configUpload(configUploadData);         
    };

    function uploadResponse(serverData){  
        try {
            var response = $.parseJSON(serverData); 
            if(response.code==404){
                alert(response.message);return false;
            }  
            var filename = response.filename;    
            var path = response.path;
            var message = response.message;
            var code = response.code;
            var extension = response.extension;
            var filesize = response.filesize;
            $("#picture").val(filename);
            $("#show_pic").html('<img src="<?php echo Yii::app()->params["urlAvatar"].$forder_upload.'/';?>'+path +'/'+ filename +'" style="width:120px;height:120px" alt="pic">');
        } catch (e) {

        };
    }

    loadBoxThongke();

    loadBoxKetQua();

    loadBoxTienIch();

    function loadBoxKetQua(){
        var url = "<?=$url->createUrl('home/boxketqua');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxketqua").html(msg);
            }
        });
    }

    function loadBoxTienIch(){
        var url = "<?=$url->createUrl('home/boxtienich');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxtienich").html(msg);
            }
        });
    }

    function loadBoxThongke(){
        var url = "<?=$url->createUrl('home/boxthongke');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxthongke").html(msg);
            }
        });
    }

    function changeInfo(){
        var url = "<?=$url->createUrl('user/changeinfo');?>";
        var mobile = $('#mobile').val();
        var picture = $('#picture').val();
        if($('#default1').prop('checked')==true){
            var radio = 'logo_avatar_acmilan.png';
        }
        if($('#default2').prop('checked')==true){
            var radio = 'logo_avatar_ars.png';
        }
        if($('#default3').prop('checked')==true){
            var radio = 'logo_avatar_barce.png';
        }
        if($('#default4').prop('checked')==true){
            var radio = 'logo_avatar_bayern.png';
        }
        if($('#default5').prop('checked')==true){
            var radio = 'logo_avatar_chese.png';
        }
        if($('#default6').prop('checked')==true){
            var radio = 'logo_avatar_real.png';
        }
        if($('#default7').prop('checked')==true){
            var radio = 'logo_avatar_mu.png';
        }
        if($('#default8').prop('checked')==true){
            var radio = 'logo_baby1.png';
        }
        if($('#default9').prop('checked')==true){
            var radio = 'logo_baby2.png';
        }
        if($('#default10').prop('checked')==true){
            var radio = 'logo_baby3.png';
        }
        if($('#default11').prop('checked')==true){
            var radio = 'logo_baby4.png';
        }
        if($('#default12').prop('checked')==true){
            var radio = 'logo_baby5.png';
        }
        if($('#default13').prop('checked')==true){
            var radio = 'logo_baby6.png';
        }
        if($('#default14').prop('checked')==true){
            var radio = 'logo_baby7.png';
        }
        if($('#default15').prop('checked')==true){
            var radio = 'logo_baby8.png';
        }
        if($('#default16').prop('checked')==true){
            var radio = 'logo_baby9.png';
        }
        if($('#default17').prop('checked')==true){
            var radio = 'logo_baby10.png';
        }
        if($('#default18').prop('checked')==true){
            var radio = 'logo_avatar_emotion1.png';
        }
        if($('#default19').prop('checked')==true){
            var radio = 'logo_avatar_emotion2.png';
        }
        if($('#default20').prop('checked')==true){
            var radio = 'logo_avatar_emotion3.png';
        }
        if($('#default21').prop('checked')==true){
            var radio = 'logo_avatar_emotion4.png';
        }
        if($('#default22').prop('checked')==true){
            var radio = 'logo_avatar_emotion5.png';
        }
        if($('#default23').prop('checked')==true){
            var radio = 'logo_avatar_emotion6.png';
        }
        if($('#default24').prop('checked')==true){
            var radio = 'logo_avatar_emotion7.png';
        }
        if($('#default25').prop('checked')==true){
            var radio = 'logo_avatar_emotion8.png';
        }
        if($('#default26').prop('checked')==true){
            var radio = 'logo_cunghoangdao1.png';
        }
        if($('#default27').prop('checked')==true){
            var radio = 'logo_cunghoangdao2.png';
        }
        if($('#default28').prop('checked')==true){
            var radio = 'logo_cunghoangdao3.png';
        }
        if($('#default29').prop('checked')==true){
            var radio = 'logo_cunghoangdao4.png';
        }
        if($('#default30').prop('checked')==true){
            var radio = 'logo_cunghoangdao5.png';
        }
        if($('#default31').prop('checked')==true){
            var radio = 'logo_cunghoangdao6.png';
        }
        if($('#default32').prop('checked')==true){
            var radio = 'logo_cunghoangdao7.png';
        }
        if($('#default33').prop('checked')==true){
            var radio = 'logo_cunghoangdao8.png';
        }
        if($('#default34').prop('checked')==true){
            var radio = 'logo_cunghoangdao9.png';
        }
        if($('#default35').prop('checked')==true){
            var radio = 'logo_cunghoangdao10.png';
        }
        if($('#default36').prop('checked')==true){
            var radio = 'logo_cunghoangdao11.png';
        }
        if($('#default37').prop('checked')==true){
            var radio = 'logo_cunghoangdao12.png';
        }
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{
                mobile: mobile,
                picture: picture,
                radio: radio,
            },
            success: function(msg){
                if(msg == 1){
                    alert('Bạn đã sửa thông tin thành công');
                    window.location = "<?php echo Yii::app()->createUrl('home/index')?>";
                }
                else{
                    $('#error').html(msg);
                }
            }
        });
    }

    function avatarBongDa(){
        var url = "<?=$url->createUrl('user/avatarbongda');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#avatar").html(msg);
            }
        });
    }

    function avatarBaby(){
        var url = "<?=$url->createUrl('user/avatarbaby');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#avatar").html(msg);
            }
        });
    }

    function avatarEmotion(){
        var url = "<?=$url->createUrl('user/avataremotion');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#avatar").html(msg);
            }
        });
    }

    function avatarHoangDao(){
        var url = "<?=$url->createUrl('user/avatarhoangdao');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#avatar").html(msg);
            }
        });
    }

</script>
<div class="leftMain">
    <div class="titleCHAT">Cập nhật thông tin</div>
    <div class="SM">
        <a href="<?php echo Yii::app()->createUrl('user/changeinfo');?>" class="button_KQ_1">Cập nhật thông tin</a>
        &nbsp;&nbsp;
        <a href="<?php echo Yii::app()->createUrl('user/changepass');?>" class="button_KQ_2">Thay đổi mật khẩu</a>
        </br>
        </br>
        <div class="SM">
            <table width="100%" class="Login">
                <tr>
                    <td><b>Tên đăng nhập:</b></td>
                    <td>
                        <?php echo $_SESSION['username'];?>
                    </td>
                </tr>
                <tr>
                    <td><b>Mobile:</b></td>
                    <td>
                        <input id="mobile" type="text" class="boxSearch" value="<?php echo $mobile;?>" style="background: #fff;">&nbsp;<span class="red">(*)</span>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <span style="font-size: 12px;">Lưu ý: nhập số mobile chính xác</span>
                    </td>
                </tr>
                <tr>
                    <td width="25%" valign="top"><b>Avartar:</b></td>
                    <td width="150%">
                        <div class="Avatar" id="avatar">
                            <ul>
                                <li>
                                    <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_acmilan.png" width="50" height="50" />
                                    </br>
                                    <input name="default" id="default1" type="radio">Default 1
                                </li>
                                <li>
                                    <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_ars.png" width="50" height="50" />
                                    </br>
                                    <input name="default" id="default2" type="radio">Default 2
                                </li>
                                <li>
                                    <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_barce.png" width="50" height="50" />
                                    </br>
                                    <input name="default" id="default3" type="radio">Default 3
                                </li>
                                <li>
                                    <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_bayern.png" width="50" height="50" />
                                    </br>
                                    <input name="default" id="default4" type="radio">Default 4
                                </li>
                                <li>
                                    <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_chese.png" width="50" height="50" />
                                    </br>
                                    <input name="default" id="default5" type="radio">Default 5
                                </li>
                                <li>
                                    <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_real.png" width="50" height="50" />
                                    </br>
                                    <input name="default" id="default6" type="radio">Default 6
                                </li>
                                <li>
                                    <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_mu.png" width="50" height="50" />
                                    </br>
                                    <input name="default" id="default7" type="radio">Default 7
                                </li>
                            </ul>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="25%"></td>
                    <td width="33%">
                        <a href="javascript:void(0);" onclick="avatarBongDa();" class="button_KQ_2">Bóng đá</a>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javascript:void(0);" onclick="avatarBaby();" class="button_KQ_2">Baby</a>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javascript:void(0);" onclick="avatarEmotion();" class="button_KQ_2">Emotion</a>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javascript:void(0);" onclick="avatarHoangDao();" class="button_KQ_2">Cung Hoàng Đạo</a>
                    </td>
                    <td width="33%">
                    </td>
                </tr>
                <tr>
                    <td width="25%" valign="top"><b>Upload:</b></td>
                    <td width="33%" valign="top">
                        <input type="text" class="boxSearch" id="txtFileName" style="background: #fff; margin: 0px" readonly="readonly"/>&nbsp;<span class="red">(*)</span>
                        <span id="spanButtonPlaceHolder" style="margin-top: 5px;"></span>
                        <br/>
                        <input type="hidden" id="picture" value=""/>
                        <p id="show_pic"></p>
                    </td>
                    <td width="33%">
                    </td>
                </tr>
                <tr>
                    <td width="25%"></td>
                    <td width="150%" style="padding: 0px 5px 0px 5px;">
                        <span style="font-size: 12px;">Lưu ý: Bạn có thể đăng nhập qua tên hoặc số điện thoại</span>
                        </br>
                        <span class="error" id="error"></span>
                    </td>
                    <td width="33%">
                    </td>
                </tr>
                <tr>
                    <td width="25%"></td>
                    <td width="33%">
                        </br>
                        <a href="javascript:void(0);" onclick="changeInfo();" class="button_KQ_1">Sửa thông tin</a>
                        &nbsp;
                        &nbsp;
                        <a href="javascript:void(0);" onclick="window.history.go(-1);" class="button_KQ_2">Quay lại</a>
                    </td>
                    <td width="33%">
                    </td>
                </tr>
            </table>   
        </div>
    </div>
</div>
<div class="rightMain">

    <div class="Box" id="boxketqua"></div>

    <div class="Box" id="boxtienich"></div>

    <div class="Box" id="boxthongke"></div>

</div>
<div class="both"></div>
